<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <th:block th:include="include :: header('监控小组人员分配')" />
    <th:block th:include="include :: bootstrap-duallistbox-css" />
</head>
<body>
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-paeaAuAuditGroupUserRel-add"><div class="ibox">
        <div class="wrapper wrapper-content animated fadeInRight ibox-content">
            <form class="form-horizontal m" id="paeaAuAuditGroup-paeaAuAuditGroupUserRel-config">
                <select id="dual_select" class="form-control dual_select" multiple>
                </select>
                <hr/>
                <div class="form-group">
                    <div class="col-sm-offset-5 col-sm-10">
                        <button type="button" class="btn btn-sm btn-primary" onclick="submitConfig()"><i class="fa fa-check"></i>保 存</button>&nbsp;
                        <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
                    </div>
                </div>
            </form>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-duallistbox-js" />
<script th:inline="javascript">
    var prefix = ctx + "oms/paeaAuAuditGroup";
    $(function () {
        var selector = $("#dual_select")[0];
        //获取所有监控人员
        var all = [[${allUsers}]];
        //获取已配置监控人员
        var assigned = [[${paeaAuAuditGroupUserRels}]];
        $(all).each(function () {
            var option = document.createElement("option");
            option.value = this["loginName"]+"@@@"+this["userName"];
            option.text = this["loginName"]+"--"+this["userName"];
            if ("undefined" != typeof (assigned) && assigned != "") {
                $.each(assigned, function (i, val) {
                    if (option.value == val["auditor"]+"@@@"+val["auditorNam"]) {
                        option.selected = 'selected';
                        return false;
                    }
                });
            }
            if(typeof(selector) != "undefined") {
                selector.options.add(option);
            }
        });

        $("#dual_select").bootstrapDualListbox({
            filterTextClear: "清空过滤条件",
            filterPlaceHolder: "过滤条件",
            nonSelectedFilter: "",
            selectedFilter: "",
            moveOnSelect: false,
            moveAllLabel: "添加全部监控人员",
            moveSelectedLabel: "添加选中的监控人员",
            removeAllLabel: "移除全部监控人员",
            removeSelectedLabel: "移除选中监控人员",
            preserveSelectionOnMove: "moved",
            helperSelectNamePostfix: "_ast",
            infoText: "共 {0} 项",
            infoTextFiltered: "从 {1} 项 筛选 {0} 项",
            infoTextEmpty:"未选择任何项",
            selectorMinimalHeight: 230
        })
    })

    //保存配置
    function submitConfig() {
        var selected = $("#dual_select").val();
        var ids = { "ids": selected==null?"":selected.join(",") }
        $.modal.confirm("确定提交当前配置的监控人员?",function(){
            $.operate.post(prefix+"/auditGroupAssignUserConfigSave/"+[[${groupId}]],ids);
        })
    }
</script>
</body>
</html>